package reggie.ruiji.mapper;
import org.apache.ibatis.annotations.*;
import reggie.ruiji.pojo.Employee;

import java.util.List;

@Mapper
public interface EmployeeMapper
{
  @Select("<script>" +
        "SELECT * FROM employee " +
        "WHERE 1=1 " +
        "<if test='name != null and name != \"\"'> " +
        "AND name LIKE CONCAT('%', #{name}, '%') " +
        "</if>" +
        "</script>")
    public List<Employee> list(String name);


    @Select("select *from employee where username=#{username}")
    public Employee selectByUsername(String username);

    @Insert("insert into employee (name,username,password,phone,sex,id_number,create_time,update_time,create_user,update_user) " +
            "values (#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser}) ")
    public void insert(Employee employee);


    //@Update("update employee set status=#{status},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    public void updateByid(Employee employee);

    @Results(
            {
                    @Result(column = "id_number",property = "idNumber")
            }
    )

    @Select("select * from employee where id=#{id}")
    public Employee selectById(Integer id);


}
